//用于远程执行的函数封装
fnc_findE5 = {
	_this sideChat (localize "STR_TAG_O_14");
};

fnc_viewMap = {
	_this sideChat format[localize "STR_TAG_O_1", floor((as_show_pos select 0) / 100), floor((as_show_pos select 1) / 100)];
};

fnc_escaped = {
	_this sideChat (localize "STR_TAG_O_2");
};

fnc_finish = {
	private _titleText = format[("<t size='1.00' color='#a81e13' align='left' shadow='1' shadowColor='#000000'>%1</t><br /><t shadow='1'shadowColor='#000000' size='0.60' color='#FFFFFF' align='left'>%2</t>"),
				localize "STR_TAG_O_6",
				"所有人都成功撤离，任务结束。Thanks for your playing，感谢你的游玩。- by略游"];
	[_titleText,[safezoneX + safezoneW - 0.8,0.50],[safezoneY + safezoneH - 0.8,0.7],10,0.5] spawn BIS_fnc_dynamicText;		
};

fnc_addAction = {
	_this addAction [format["<t color=""#00ff00"">%1</t><t color=""#d50e0e"">[+300]</t>", localize "STR_TAG_O_3"], {
		params ["_target", "_caller", "_actionId", "_arguments"];
		_target removeAction  _actionId;
		moveOut _target;
		private _money =  _target getVariable["as_money", 0];
		_target setVariable ["as_money", _money + 300, true];
		private _veh = createVehicle ["O_Heli_Attack_02_dynamicLoadout_F", position _target, [], 200, "FLY"];
		[_target, _veh] spawn{
			params ["_target", "_veh"];
			waitUntil{Sleep 1;_target moveInDriver _veh; vehicle _target == _veh};
		};
		private _unit = group _target createUnit ["O_T_Helicrew_F", position _target, [], 200, "FORM"];
		_unit moveInGunner _veh;
		as_escape_used = true;
	}, [],103, false, true, "", "isNil 'as_escape_used'"];
	
	_this addAction  [format["<t color=""#00ff00"">%1</t><t color=""#d50e0e"">[+200]</t>", localize "STR_TAG_O_4"], {
		params ["_target", "_caller", "_actionId", "_arguments"];
		_target removeAction  _actionId;
		moveOut _target;
		private _money =  _target getVariable["as_money", 0];
		_target setVariable ["as_money", _money + 200, true];
		private _veh = createVehicle ["O_Plane_CAS_02_dynamicLoadout_F", position _target, [], 200, "FLY"];
		[_target, _veh] spawn{
			params ["_target", "_veh"];
			waitUntil{Sleep 1;_target moveInDriver _veh; vehicle _target == _veh};
		};
		as_escape_used = true;
	}, [],102, false, true, "", "isNil 'as_escape_used'"];
	
	
	_this addAction [format["<t color=""#00ff00"">%1</t><t color=""#d50e0e"">[+100]</t>", localize "STR_TAG_O_5"], {
		params ["_target", "_caller", "_actionId", "_arguments"];
		_target removeAction  _actionId;
		private _money =  _target getVariable["as_money", 0];
		_target setVariable ["as_money", _money + 100, true];
		as_end_state = 1;publicVariable "as_end_state";
		as_escape_used = true;
		}, [],101, false, true, "", "isNil 'as_escape_used'"];
};


fnc_newPlayer = {
	//头盔
	_this addHeadgear (selectRandom ash_ai_3);
	
	//夜视仪
	_this addItem "O_NVGoggles_ghex_F";
	_this assignItem "O_NVGoggles_ghex_F";
	
	//背心
	_this addVest "V_TacVest_blk_POLICE";//";
	
	//黄包
	_this addItem "FirstAidKit";//急救箱 x5
	_this addItem "FirstAidKit";//急救箱
	_this addItem "FirstAidKit";//急救箱
	_this addItem "FirstAidKit";//急救箱
	_this addItem "FirstAidKit";//急救箱
	
	//地图
	_this addItem "ItemMap";  
	_this assignItem "ItemMap";  
	_this addItem "ItemRadio";  
	_this assignItem "ItemRadio"; 
	
	//武器（避免模组的干扰）//[3, _this] call fn_initWeapon;
	
	
	private _one = selectRandom asw_new;
	private _weapon = selectRandom _one;
	if(typeName _weapon != "STRING"
	|| {getText(configfile >> "CfgWeapons" >> _weapon >> "author") == ""}) then
	{
		_weapon = _one select 1;
	};
	private _mags = _weapon call fn_getWeaponMag;
	for "_i" from 1 to 4 do
	{
		_this addMagazineGlobal (selectRandom _mags);
	};
	_this addWeaponGlobal _weapon;
	
	
	//配件addPrimaryWeaponItem
	_this addItem "optic_MRCO";//(selectRandom selectRandom asp_ai_2);
};


//掉落发射器
fnc_dropLaunch = {
	private _name = secondaryWeapon _this;
	private _mags = secondaryWeaponMagazine _this;//只返回筒子加载的弹药
	_this removeWeaponGlobal _name;
	
	private _gh = "GroundWeaponHolder_Scripted" createVehicle (position _this);

	_gh addWeaponCargoGlobal [_name, 1];
	{
		_gh addMagazineCargoGlobal [_x, 1];
	}forEach _mags;
};